<?php
namespace Home\Controller;

use Think\Controller;

/**
 * UserController
 * 快递对接、注册、提货、拒签
 * @package
 * @author zhou
 * @copyright 2016.12
 * @version $Id$
 * @access public
 */
class ExpressController extends Controller
{
    /**
     * 中通注册请求参数
     * 测试地址：
     * UTF-8:    http://58.40.16.125:9001/zto/api_utf8/kdService
     * 正式地址：
     * UTF-8:  http://japi.zto.cn/zto/api_utf8/kdService
     */
    private $Zhongtong_Url = 'http://japi.zto.cn/zto/api_utf8/kdService';

    /**
     * @desc 韵达请求地址
     * @author quyang
     * @update 2017-1-3
     * @param  测试地址 :
     *              http://116.228.72.130:15137/cmn-web/getway
     *         正式地址：
     *              http://180.153.139.84:11381/cmn-web/getway
     */
    private $yundan_Url = 'http://180.153.139.84:11381/cmn-web/getway';

    // 圆通参数
    private $YT_REQ = array(
        'encrpteKey' => "Y34IHTg117q8OZog", // key
        'positionCode' => "0200", // 站点位置属性
        'operateCode' => "0000", // 经营类型
        'stationType' => "5501", // 站点请求类型 代办
        'logisticsCode' => "BLC00001", // 快递公司编号
        'customerCode' => "vncwyvsy", // 客户渠道编码
//        'url' => "http://jingangtest.yto56.com.cn/stationin/post", // 测试地址
        'url' => "http://interface.mamayz.com/stationin/post", // 正式地址
        'op_code_register' => "0000", // 注册识别
        'op_code_put' => "1730", // 入库识别
        'op_code_sign' => "1745", // 签收识别
        'op_code_reject' => "1746", // 拒收识别
        'op_code_return' =>'1783',  //包裹多日无人签收
        'deliveryFallReasonCode_one' => "0401", // 拒收原因类型 包裹破损
        'deliveryFallReasonCode_two' => "0403", // 拒收原因类型 延时通知
        'deliveryFallReasonCode_three' => "2501", // 拒收原因类型 快递员带走
        'deliveryFallReasonCode_four' => "0404", // 拒收原因类型 其他原因拒收
    );
    
    /**
     * @desc 德邦请求地址
     * @author cheng
     * @update 2017-06-09
     * 测试地址： http://58.40.17.67:10167/dop-interface-sync/cainiaotrace/tbWFTraceOrderCN.action
     * 正式地址： http://dpapi.deppon.com/dop-interface-sync/cainiaotrace/tbWFTraceOrderCN.action
     */
//    private $Debang_Url = 'http://58.40.17.67:10167/dop-interface-sync/cainiaotrace/tbWFTraceOrderCN.action';
    private $Debang_Url = 'http://58.40.17.67:10209/dop-interface-sync/cainiaotrace/tbWFTraceOrderCN.action';

    /**
     * @desc 扫描队列表获取请求状态为0的进行请求
     * @author quyang
     * @update 2016-12-21
     */
    public function expressScanning(){
        $curday = date('YmdHis');
        $times = date('YmdHis', strtotime('-1 hour'));
        //筛选条件
        $map_sto['f_create_time'] = array('between', array($times, $curday));
        $map_sto['_string'] = '(f_type=1 AND f_storage_status=0) OR (f_type=2 AND f_arrive_status=0) OR (f_type=3 AND f_rejection_status=0) OR (f_type=4 AND f_two_library_status=0)';
        $parcelInfo = new \Home\Model\StationAbutmentLogModel();
        $data = $parcelInfo->queryExpressData($map_sto);
        foreach ($data as $v) {
            if ($v['f_com_id'] == '125') {
                $sto_date[] = $v;
            }
            if ($v['f_com_id'] == '109') {
                $yunda_data[] = $v;
            }
            if ($v['f_com_id'] == '115') {
                $uop_data[] = $v;
            }
            if ($v['f_com_id'] == '108') {
                $yt_data[] = $v;
            }
            if ($v['f_com_id'] == '182') { //德邦
                $db_date[] = $v;
            }
        }
        if (!empty($sto_date)) {
            $this->stoStorage($sto_date);
        }
        if (!empty($yunda_data)) {
            $this->yundaStorage($yunda_data);
        }
        if (!empty($uop_data)) {
            $this->UOPStorage($uop_data);
        }
        if (!empty($yt_data)) {
            $this->YTStorage($yt_data);
        }
        if (!empty($db_date)) {
            $this->DBStorage($db_date);
        }
    }

    /**
     * @desc 组织数据向中通发送请求
     * @author quyang
     * @update 2016-12-21
     */
    public function stoStorage($arr){
        foreach ($arr as $value) {
            if ($value['f_type'] == '1') {
                $type = 'ARRIVAL';
                $project = 'f_storage_status';
            } elseif ($value['f_type'] == '2'){
                $type = 'SIGNED';
                $project = 'f_arrive_status';
            } elseif ($value['f_type'] == '3'){
                $type = 'RETURNED';
                $project = 'f_rejection_status';
            }

            $data = array(
                'comCode' => '1029',
                'billCode' => $value['f_mail_no'],
                'type' => $type,
                'optDate' => date('Y-m-d H:i:s'),
                'facilityNo' => 'xmks' . $value['f_station_id'],
                'facilityName' => $value['f_station_name'],
                'contacter' => $value['f_tel'],
                'payMoney' => '0',
                'returnMoney' => '0',
                'payType' => 'NOPAY',
                'deliverName' => 'notsure',
            );
            $list['data'] = json_encode($data);
            $list['data_digest'] = base64_encode(md5($list['data'] . 'XMKSFGHJKKJV76==', True));
            $list['msg_type'] = 'DISP_INFO_FEEDBACK';
            $list['company_id'] = '1029';
            //请求接口
            $Return = use_CURL($this->Zhongtong_Url, True, $list);
            $Return_Data = json_decode($Return['content'], true);

            dump($Return_Data);

            if (empty($Return_Data)) {
                $where = array($project => '2', 'f_error' => '请求失败');
            }
            if ($Return_Data['status'] == true) {
                $where = array($project => '1');
            } else{
                $where = array($project => '2', 'f_error' => $Return_Data['msg']);
            }
            $parcelInfo = new \Home\Model\StationAbutmentLogModel();
            $parcelInfo->updateExpressData($value['f_parcel_id'], $where);
        }
    }

    /**
     * 提取XML中数据
     * @param string $XML_Content
     * @return array
     */
    private function XML_To_Array($XML_Content = ''){
        $xmlResult = xml_parser_create();
        xml_parse_into_struct($xmlResult, $XML_Content, $Array);
        xml_parser_free($xmlResult);

        $Data = Array();

        foreach ($Array as $val) {
            if (isset($val['value']) && $val['value'] != '') {
                $Data[$val['tag']] = $val['value'];
            }
        }

        return $Data;
    }

    /**
     * @desc 韵达请求
     * @author quynag
     * @update 2017-1-3
     */
    public function yundaStorage($data){
        $scanTime = date('Y-m-d H:i:s');
        foreach ($data as $value) {
            //查询站点注册信息
            $where = array('f_station_id' => $value['f_station_id'], 'f_com_id' => '109', 'f_status' => '1');
            $express = new \Home\Model\StationRegisterModel();
            $arr = $express->queryExressCooperation($where);
            $name = $value['f_recipient_name'];
            if (empty($value['f_recipient_name'])) {
                $name = '草签';
            }
            //根据类型不同更改不同的状态值，发送不同的请求
            if ($value['f_type'] == '1') {
                $xmldata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
                    "<request>" .
                    "<company>" . $arr['f_orgCode'] . "</company>" .
                    "<scanList><scan><waybill>" . $value['f_mail_no'] . "</waybill>" .
                    "<scanTime>" . $scanTime . "</scanTime></scan></scanList>" .
                    "</request>";
                $project = 'f_storage_status';
                $urlType = '/arrival_scan_info.do';
            } elseif ($value['f_type'] == '2'){
                $xmldata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
                    "<request>" .
                    "<company>" . $arr['f_orgCode'] . "</company>" .
                    "<scanList><scan><waybill>" . $value['f_mail_no'] . "</waybill>" .
                    "<signStatus>1</signStatus>" .
                    "<signName>" . $name . "</signName>" .
                    "<scanTime>" . $scanTime . "</scanTime></scan></scanList>" .
                    "</request>";
                $project = 'f_arrive_status';
                $urlType = '/sign_scan_info.do';
            } elseif ($value['f_type'] == '3'){
                $xmldata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
                    "<request>" .
                    "<company>" . $arr['f_orgCode'] . "</company>" .
                    "<scanList><scan><waybill>" . $value['f_mail_no'] . "</waybill>" .
                    "<signStatus>0</signStatus>" .
                    "<signExcp>" . $value['f_common'] . "</signExcp>" .
                    "<signName>" . $name . "</signName>" .
                    "<scanTime>" . $scanTime . "</scanTime></scan></scanList>" .
                    "</request>";
                $project = 'f_rejection_status';
                $urlType = '/sign_scan_info.do';
            }

            //驿站编号
            $list['partnerid'] = urldecode($arr['f_stationCode']);
            //版本号
            $list['version'] = urlencode('1.1.0');
            //xml数据base64位加密
            $list['xmldata'] = urlencode(base64_encode($xmldata));

            $list['appkey'] = urldecode($arr['f_appkey']);

            //32位MD5(xmldata + partnerid + 密码 + appkey)
            $list['validation'] = urldecode(md5(base64_encode($xmldata) . $arr['f_stationCode'] . $arr['f_password'] . $arr['f_appkey']));

            //组织入库url地址
            $url = $this->yundan_Url . $urlType;

            $return_data = send_yunda($url, $list);

            $res = $this->XML_To_Array($return_data);

            if (empty($res)) {
                $where = array($project => '2', 'f_error' => '请求失败');
            }
            if ($res['STATUS'] == 'true') {
                $where = array($project => '1');
            } else{
                $where = array($project => '2', 'f_error' => $res['MSG']);
            }
            $parcelInfo = new \Home\Model\StationAbutmentLogModel();
            $parcelInfo->updateExpressData($value['f_parcel_id'], $where);
        }
    }

    /**
     * UOP请求优速
     * http://localhost/xmbg-api/index.php?reqUrl=Express.expressScanning
     * youtanzhi
     */
    public function UOPStorage($dataList){
        // 构造参数
        $param = Array();
        $receivePush = Array();
        $trace = Array();
        $parcelDat = Array();
        foreach ($dataList as $data) {
            $parcelId = $data['f_parcel_id'];

            $where = '`f_parcel_id`='.$parcelId.'';
            $parcelInfo = new \Home\Server\QueryParcelService();
            $lastTime = $parcelInfo->queryParcelStatus( $where );

            $lastTime = $lastTime['f_last_time'];
            $time = date("Y年n月j日 ag:i:s", strtotime($lastTime));
            $time = str_replace('am', "上午", $time);
            $time = str_replace('pm', "下午", $time);
            $parcelDat['scanTime'] = date("Y-m-d H:i:s", time());
            $parcelDat['context'] = "快件已到【熊猫快收】" . "【" . $data['f_station_name'] . "】代收货自提点，联系方式：" . $data['f_tel'];
            if ($data['f_type'] == 1) {
                $reqType = array('f_storage_status' => '0');
                $parcelDat['scanType'] = "0";// 请求类型 在途
            } elseif ($data['f_type'] == 2){
                $reqType = array('f_arrive_status' => '0');
                $parcelDat['scanType'] = "15";// 请求类型 签收
                $parcelDat['context'] = "快件已于" . $time . "在【熊猫快收】【" . $data['f_station_name'] . "】代收货自提点成功提货/签收";
            } else{
                $reqType = array('f_rejection_status' => '0');
                $parcelDat['scanType'] = "0";// 请求类型 在途
            }
            $parcelDat['siteName'] = $data['f_station_name'];
            $parcelDat['mobile'] = $data['f_tel'];
            $trace['trace'] = $parcelDat;
            $receivePush['billCode'] = $data['f_mail_no'];
            $receivePush['traces'] = $trace;
            $param['receivePush'] = $receivePush;
            $this->doPostUOP($data['f_parcel_id'], json_encode($param), $reqType);
        }
    }

    /**
     * 请求UOP
     * youtanzhi
     */
    public function doPostUOP($parcelId, $param, $reqType){
        // 测试
        // $UOPeceiveUrl = "http://113.106.93.46/com.uc56.uop.main/peerturn/peerturn.action";
        // 正式
        $UOPeceiveUrl = "http://uop.uc56.com/peerturn/peerturn.action";
        // $UOPeceiveUrl = "http://180.168.24.22:18081/zhouhanxiu/com.uc56.uop.main/peerturn/peerturn.action";
        $secretKey = "640ceab0d3b38b96c13fd13b2b2d9379";
        //$secretKey = "88dd36a8b86d6e7eb454adfe689e2eed";
        $partner = "80411613";
        // $partner = "90000007";
        $serviceName = "receive_track";
        $dataType = "json";
        // 拼接加密字符串
        $data = Array();
        $data[0] = "dataType" . "=" . $dataType;
        $data[1] = "param" . "=" . $param;
        $data[2] = "partner" . "=" . $partner;
        $data[3] = "serviceName" . "=" . $serviceName;
        $comma_separated = implode("&", $data);
        // 加密最后结果
        $dataSign = md5($comma_separated . $secretKey);
        $Request_Data['dataSign'] = $dataSign;
        $Request_Data['partner'] = $partner;
        $Request_Data['serviceName'] = $serviceName;
        $Request_Data['dataType'] = $dataType;
        $Request_Data['param'] = $param;
        // 请求UOP平台
        $postdata = http_build_query($Request_Data);
        $options = array(
            'http' => array(
                'method' => 'POST',
                'header' => 'Content-type:application/x-www-form-urlencoded',
                'content' => $postdata,
                'timeout' => 5 * 60 // 超时时间（单位:s）
            )
        );
        $context = stream_context_create($options);
        $result = file_get_contents($UOPeceiveUrl, true, $context);
        $xml = simplexml_load_string('<?xml version="1.0" encoding="gbk"?>' . $result);
        $re = (string)$xml->returnCode;
        // 请求成功更新包裹状态
        if ($re == "SUCCESSFUL") {
            // 更新包裹状态
            foreach ($reqType as $key => $val) {
                $reqType[$key] = 1;
            }
        } else{
            foreach ($reqType as $key => $val) {
                $reqType[$key] = 2;
            }
        }
        $parcelInfo = new \Home\Model\StationAbutmentLogModel();
        $parcelInfo->updateExpressData($parcelId, $reqType);
    }

    /**
     * Desc:圆通包裹数据处理
     * User:youtanzhi
     * Date:2017-02-14 10:36:50
     * 测试url：http://localhost/xmbg-api/index.php?reqUrl=Express.expressScanning
     */
    public function YTStorage($dataList){
        foreach ($dataList as $data) {
            $stationId = $data["f_station_id"];
            // 获取站点注册圆通信息
            $stationRegister = new \Home\Model\StationRegisterModel();
            $where = array("f_station_id" => $stationId, "f_com_id" => "108", "f_status" => "1");
            $result = $stationRegister->queryExressCooperation($where);
            // 组织请求包裹数据
            $parcelId = $data["f_parcel_id"];
            // 查询收件人姓名
            $startTime = $data["startTime"] = date("Y-m-d", strtotime("-1 month"));
            $lastTime = $data["startTime"] = date('Y-m-d', time());
            $parcelService = new \Home\Server\ParcelService();
            $parcelData = $parcelService->getConditionStorage($stationId, "", "", -1, "", ""
                , "", $data["f_mail_no"], "", $startTime, $lastTime, "");
            $fRecipientMobile = $parcelData[0]["fRecipientMobile"];
            if (empty($fRecipientMobile)) {
                $fRecipientMobile = $data["f_tel"]; // 收件人手机号码为空时，默认为站点手机号
            }
            $logisticsInterface["waybillNo"] = $data["f_mail_no"];

            if ($data["f_type"] == "1" && $data['f_storage_status'] == '0') {
                $logisticsInterface["opCode"] = $this->YT_REQ["op_code_put"]; // 入库
                $logisticsInterface["previousOrgCode"] = $result["f_orgCode"];
                $logisticsInterface["empCode"] = $result["f_empCode"];
            }

            if ($data["f_type"] == "2") {
                $logisticsInterface["opCode"] = $this->YT_REQ["op_code_sign"]; // 签收
                $logisticsInterface["recieverSigNoff"] = $data['f_recipient_name'];
                if (empty($logisticsInterface["recieverSigNoff"])) {
                    $logisticsInterface["recieverSigNoff"] = "草签";
                }
                $logisticsInterface["recieverPhone"] = $fRecipientMobile;
            }

            if ($data["f_type"] == "3") {
                $logisticsInterface["opCode"] = $this->YT_REQ["op_code_reject"]; // 拒收
                if ($data["f_common"] == "包裹破损") {
                    $logisticsInterface["deliveryFallReasonCode"] = $this->YT_REQ["deliveryFallReasonCode_one"]; // 包裹破损
                    $logisticsInterface["deliveryFallReason"] = "快件破损、变形、内件短少"; // 拒收理由
                } elseif ($data["f_common"] == "延时通知"){
                    $logisticsInterface["deliveryFallReasonCode"] = $this->YT_REQ["deliveryFallReasonCode_two"]; // 延时通知
                    $logisticsInterface["deliveryFallReason"] = "因派送延误拒收"; // 拒收理由
                } elseif ($data["f_common"] == "快递员带走"){
                    $logisticsInterface["deliveryFallReasonCode"] = $this->YT_REQ["deliveryFallReasonCode_three"]; // 快递员带走
                    $logisticsInterface["deliveryFallReason"] = "客户逾期未取退回业务员"; // 拒收理由
                } else{
                    $logisticsInterface["deliveryFallReasonCode"] = $this->YT_REQ["deliveryFallReasonCode_four"]; // 其他
                    $logisticsInterface["deliveryFallReason"] = $data["f_common"]; // 拒收理由
                }
            }

            //当日已到站为提货发送请求
            if ($data["f_type"] == "1" && $data['f_storage_status'] != '0'){
                $logisticsInterface["opCode"] = $this->YT_REQ["op_code_reject"]; // 拒收
                $logisticsInterface["deliveryFallReasonCode"] = $this->YT_REQ["deliveryFallReasonCode_four"]; // 其他
                $logisticsInterface["deliveryFallReason"] = '用户未取件'; // 拒收理由
                //当日未提类型为 4 不做数据更改
                $data["f_type"] = '4';
            }

            $logisticsInterface["opTime"] = date("Y-m-d H:i:s", time());
            $logisticsInterface["opUserId"] = $data["f_tel"];
            $logisticsInterface["logisticsCode"] = $this->YT_REQ["logisticsCode"]; // 快递公司编号
            $logisticsInterface["stationCode"] = $result["f_stationCode"]; // 驿站编号
            $logisticsInterface["customerCode"] = $this->YT_REQ["customerCode"];
            $logistics_interface = arrayToXml($logisticsInterface);
            $orgCode = $result["f_orgCode"];
            $this->doPostYT($parcelId, $logistics_interface, $logisticsInterface["opCode"], $orgCode, $data["f_type"]);
        }
    }

    /**
     * Desc:请求圆通
     * User:youtanzhi
     * Date:2017-02-14 10:37:58
     */
    public function doPostYT($parcelId, $param, $reqType, $orgCode, $type){
        $YTUrl = $this->YT_REQ['url'];
        // 请求参数
        $Request_Data['logistics_interface'] = $param;
        $md5 = md5($Request_Data['logistics_interface'] . $this->YT_REQ['encrpteKey'], 1);
        $Request_Data['data_digest'] = base64_encode($md5);
        $Request_Data['customer_code'] = $this->YT_REQ['customerCode']; // 客户渠道编码
        $Request_Data['op_code'] = $reqType; // 请求识别码
        $Request_Data['station_type'] = $this->YT_REQ['stationType']; // 站点请求类型
        $Request_Data['org_code'] = $orgCode; // 网点编码
        // 请求YT平台
        $postdata = http_build_query($Request_Data);
        $options = array(
            'http' => array(
                'method' => 'POST',
                'header' => 'Content-type:application/x-www-form-urlencoded',
                'content' => $postdata,
                'timeout' => 5 * 60 // 超时时间(单位:s)
            )
        );
        $context = stream_context_create($options);
        $result = file_get_contents($YTUrl, true, $context);
        $xml = simplexml_load_string('<?xml version="1.0" encoding="gbk"?>' . $result);
        $accept = (string)$xml->accept;

        // 更新队列表包裹状态
        $stationAbutment = new \Home\Model\StationAbutmentLogModel();
        if ($type == "1") {
            if ($accept == "success") {
                $data["f_storage_status"] = "1";
            } else{
                $data["f_storage_status"] = "2";
                $data["f_error"] = (string)$xml->errorCode;
            }
        }
        if ($type == "2") {
            if ($accept == "success") {
                $data["f_arrive_status"] = "1";
            } else{
                $data["f_error"] = (string)$xml->errorCode;
                $data["f_arrive_status"] = "2";
            }
        }
        if ($type == "3") {
            if ($accept == "success") {
                $data["f_rejection_status"] = "1";
            } else{
                $data["f_error"] = (string)$xml->errorCode;
                $data["f_rejection_status"] = "2";
            }
        }

        if ( !empty($data) ){
            $stationAbutment->updateExpressData($parcelId, $data);
        }

    }

    /**
     * @Desc  : 查询圆通当日未提件
     * @Author：quyang
     * @Param ：
     * @Time  ：2017/3/3 9:55
     * @Update：2017/3/3
     **/
    public function queryYtOvertime()
    {

        $Abument = new \Home\Model\StationAbutmentLogModel();

        $where = '`f_type`=1 AND `f_storage_status`!=0 AND f_create_time BETWEEN '.date('Ymd000000').' AND '.date('Ymd235959').'';

        $data = $Abument->queryExpressData( $where );

        //组织数据向圆通发送当日未提请求
        $this->YTStorage( $data );

    }

    /**
     * 德邦包裹数据处理
     * @author cheng 复制修改
     */
    public function DBStorage($arr) {
        $User = new \Home\Model\UserModel();
        foreach ($arr as $value) {
            if ($value['f_type'] == '1') {
                $opt_info = ['action' => 'STA_INBOUND', 'desc' => '快件已由' . $value['f_station_name'] . '熊猫驿站代收，请及时取件，如有疑问请联系' . $value['f_tel']];
                $project = 'f_storage_status';
            } elseif ($value['f_type'] == '2') {
                $opt_info = ['action' => 'STA_SIGN', 'desc' => '已签收，签收人凭取货码签收'];
                $project = 'f_arrive_status';
            } elseif ($value['f_type'] == '3') {
                $j_msg = !empty($value['f_common']) ? '拒收原因：' . $value['f_common'] : '';
                $opt_info = ['action' => 'STA_BUYER_REJECT', 'desc' => '快件在' . $value['f_station_name'] . '熊猫驿站被您拒收。' . $j_msg];
                $project = 'f_rejection_status';
            } elseif ($value['f_type'] == '4') {
                $j_msg = !empty($value['f_common']) ? $value['f_common'] : '快递员带走';
                $opt_info = ['action' => 'STA_MAILMAN_PICKUP', 'desc' => '备注原因：' . $j_msg . '，如有疑问请联系' . $value['f_tel']];
                $project = 'f_two_library_status';
            }
            //获取城市信息，组织数据
            $area_info = $User->getArea($value['f_station_id']);
            $data = [
                'action' => $opt_info['action'],
                'cnOrderCode' => 'XM' . $value['f_mail_no'],
                'desc' => $opt_info['desc'],
                'mailNos' => $value['f_mail_no'],
                'city' => $area_info['f_city_name'] ? $area_info['f_city_name'] : '未知',
                'partnerName' => '熊猫快收',
                'stationContact' => $value['f_tel'],
                'stationName' => $value['f_station_name'],
                'stationSource' => '2',
                'time' => date('Y-m-d H:i:s')
            ];

            $list['logistics_interface'] = json_encode($data);
            //请求接口
            $Return = use_CURL($this->Debang_Url, True, $list);
            $Return_Data = json_decode($Return['content'], true);

            //dump($data);

            if (empty($Return_Data)) {
                $where = array($project => '2', 'f_error' => '请求失败');
            }
            if ($Return_Data['success'] == true) {
                $where = array($project => '1');
            } else{
                $where = array($project => '2', 'f_error' => $Return_Data['errorCode']);
            }
            $parcelInfo = new \Home\Model\StationAbutmentLogModel();
            $parcelInfo->updateExpressData($value['f_parcel_id'], $where);
        }
    }
    
}